<template>
  <div class="main" v-color="'bgkImg'">
    <dz-nav :is-back="true" back-url="/record">
      <template #center>
        <b v-color><qq>missionDetails</qq></b>
      </template>
    </dz-nav>
    <div class="box-1">
      <div class="header">
        <img src="@/assets/images/avatar.png" alt="">
        <div class="right">
          <div class="top-1">
            <span><qq>demandSide</qq></span>
            <div class="tips">
              Mobile authentication
            </div>
          </div>
          <p class="top-2">
            <span><qq>Reviewstandards</qq>:</span>
          </p>
        </div>
      </div>
      <div class="url">
        {{ form.url }}
      </div>

      <div class="box-3">
        <p class="nav">
          <span><qq>Tasktitle</qq> </span> <b>{{ form.taskTitle }}</b>
        </p>
        <p class="nav">
          <span><qq>Income</qq></span> <b>{{ (form.forwardAmount+form.dailyAmount+form.reviewAmount).toFixed(2) }}USDT</b>
        </p>
        <p class="nav">
          <span><qq>MissionDetails</qq> </span> <b>comment,like</b>
        </p>
        <p class="nav">
          <span><qq>Require</qq> </span> <b>Subscribe and like</b>
        </p>
        <p class="nav">
          <span><qq>Upload</qq> </span>
          <van-uploader :after-read="beforeRead" >
          <i v-if="!img">
            <img src="@/assets/images/Trendingdown2x.png" alt="">
          </i>
            <img  v-else class="imgUrl" :src="img" alt="">
          </van-uploader>
        </p>
        <div class="bottom">
          <img @click="submit(1)" src="@/assets/images/del.png" alt="">
          <img @click="submit(2)" src="@/assets/images/btn-link.png" alt="">
          <img @click="submit(3)" src="@/assets/images/detail.png" alt="">
          <img @click="submit(4)" src="@/assets/images/checked.png" alt="">
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import {getItem, removeItem} from "@/utils/auth";
import {applyTaskOrderApproval, delTaskOrder, uploadV2} from "@/api/apiFox";
import {Toast} from "vant";

  export default {
    data(){
      return{
        form:{},
        img:''
      }
    },
    methods:{
      submit(item){
        switch (item) {
          case 1:{
            delTaskOrder(this.form.idw).then(res=>{
              this.$router.go(-1)
              removeItem('mission')
            }).catch(err=>{})
            break
          }
          case 2:{
            window.open(this.form.url)
            break
          }
          case 3:{
            this.oncopy(this.form.url)
            break
          }
          case 4:{
              if (this.img){
                applyTaskOrderApproval({approvalPic:this.img,id:this.form.id}).then(res=>{
                  Toast.success(this.$t('Success'))
                  this.img  = ''
                  this.$router.go(-1)
                  removeItem('mission')
                }).catch(err=>{})
              }else{
                Toast.fail(this.$t('uploadFile'))
              }
          }
        }
      },
      oncopy(code){
        this.$copyText(code).then(
            e=>{
              Toast({
                position:'center',
                message:this.$t('Success')
              })
            },
            e=>{
              console.log('error：', e);
            }
        )
      },
      beforeRead(file){
        uploadV2(file).then(res=>{
          console.log(res)
          this.img = res.url
        }).catch(err=>{})
      }
    },
    mounted() {
      this.form = getItem('mission')
      console.log(getItem('mission'))
    },
    destroyed() {
      // removeItem('mission')
    }
  }
</script>

<style scoped lang="scss">
.main{
  width: 100%;
  min-height: 100vh;
  .box-1{
    width: 375px;
    min-height: calc(100vh - 50px);
    background: linear-gradient( 180deg, #FFF0C9 0%, #D49188 100%);
    box-shadow: inset 0px 4px 4px 0px rgba(255,255,255,0.25);
    border-radius: 30px 30px 0px 0px;
    padding: 13px 16px;
    box-sizing: border-box;
    .header{
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      img{
        object-fit: cover;
        width: 44px;
        height: 44px;
      }
      .right{
        width: 100%;
        margin-left: 10px;

        .top-1{
          width: 100%;
          font-weight: 500;
          font-size: 12px;
          color: #3F3F3F;
          display: flex;
          align-items: center;
          span{
            font-weight: 500;
            font-size: 12px;
            color: #3F3F3F;
            margin-right: 10px;
          }
          .tips{
            padding: 2px 5px;
            border-radius: 10px;
            background: #fff;
            color: #558CDE;
          }
        }
        .top-2{
          width: 100%;
          font-weight: 500;
          font-size: 12px;
          color: #3F3F3F;
          margin-top: 5px;
        }
      }
    }
    .url{
      width: 350px;
      overflow: scroll;
      font-weight: 500;
      font-size: 12px;
      color: #5A4CBB;
      margin-top: 8px;
    }

    .box-3{
      width: 343px;
      height: 265px;
      background: #FFFFFF;
      border-radius: 20px 20px 20px 20px;
      margin-top: 30px;
      padding: 24px 16px;
      box-sizing: border-box;
      .nav{
        font-weight: 400;
        font-size: 12px;
        color: #5B6B86;
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        span{
          display: flex;
          width: 30%;
          font-weight: 800;
          i{
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: left;
            height: 20px;
            background: none;
          }
        }
        b{
          font-weight: bold;
          font-size: 14px;
          color: #533DF1;
          width: 70%;
        }
        i{
          display: flex;
          width: 62px;
          height: 41px;
          background: #E5E5EA;
          border-radius: 10px 10px 10px 10px;
          justify-content: center;
          align-items: center;
          img{
            width: 24px;
            height: 24px;
            object-fit: cover;
          }
        }
        .imgUrl{
          width: 45px;
          height: 45px;
          object-fit: cover;
        }
      }
      .bottom{
        width: 100%;
        margin-top: 10px;
        img{
          width: 28px;
          height: 28px;
          object-fit: cover;
          margin-right: 20px;
        }
      }
    }
  }
}
</style>